#ifndef __SEARCHENGINESERVER_HPP__
#define __SEARCHENGINESERVER_HPP__

#include "ThreadPool.hpp"
#include "TcpServer.hpp"
#include "../online/KeyRecommander.hpp"
/* #include "KeyRecommander.hpp" */
/* #include "WebPageSearcher.hpp" */
#include "../online/WebPageSearcher.hpp"
#include "ProtocolParser.hpp"
#include "../online/CacheManager.hpp"


class SearchEngineServer
{
public:
    SearchEngineServer(size_t threadNum, size_t queSize, const string &ip, unsigned short port);
    ~SearchEngineServer();
    void start();
    void stop();
    void onConnection(const TcpConnectionPtr &con);
    void onMessage(const TcpConnectionPtr &con);
    void onClose(const TcpConnectionPtr &con);
    void doTaskThread(const TcpConnectionPtr&, string &msg);

private:
    ThreadPool _threadpool; //Tcp通信模块
    TcpServer _tcpserver;   //线程池
    ProtocolParser _protocolParser;     //协议解析模块
    /* CacheManager *_cacheManager; //缓存 */
};

#endif
